load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "dbutil",
    srcs = [
        "common.go",
        "index.go",
        "interface.go",
        "query.go",
        "retry.go",
        "table.go",
        "types.go",
        "variable.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/util/dbutil",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/ddl",
        "//pkg/errno",
        "//pkg/infoschema",
        "//pkg/parser",
        "//pkg/parser/ast",
        "//pkg/parser/auth",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/planner/core",
        "//pkg/types",
        "//pkg/types/parser_driver",
        "//pkg/util",
        "//pkg/util/collate",
        "//pkg/util/dbterror",
        "@com_github_go_sql_driver_mysql//:mysql",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_log//:log",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "dbutil_test",
    timeout = "short",
    srcs = [
        "common_test.go",
        "index_test.go",
        "retry_test.go",
        "table_test.go",
        "variable_test.go",
    ],
    embed = [":dbutil"],
    flaky = True,
    deps = [
        "//pkg/errno",
        "//pkg/infoschema",
        "//pkg/parser",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/types",
        "//pkg/util/schemacmp",
        "@com_github_data_dog_go_sqlmock//:go-sqlmock",
        "@com_github_go_sql_driver_mysql//:mysql",
        "@com_github_pingcap_errors//:errors",
        "@com_github_stretchr_testify//require",
    ],
)
